package JavaEE_notes.common_API;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @description 日期格式化 API 示例
 * @author TaiZai
 * @data 2024/9/20 14:34
 */
public class api_SimpleDateFormat {
    public static void main(String[] args) {
        Date date = new Date();
        System.out.println(date);
        long time = date.getTime();
        System.out.println(time);

        // SimpleDateFormat 类提供格式化和解析日期的功能
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String res1 = sdf.format(date);
        System.out.println(res1);
        String res2 = sdf.format(time);
        System.out.println(res2);


    }
}
